<?php
namespace app\api\controller;

use app\common\exception\BusinessException;
use think\response\Json;

class VipCourse extends Base
{

    /**
     * VIP课程列表
     * @return Json
     * @throws BusinessException
     */
    public function getList(): Json
    {
        //外部参数
        $param = $this->request->param();

        //验证规则
        $rule = [
            'professions_id' => 'require'
        ];

        //错误信息
        $errMsg = [
            'professions_id.require' => '专业id不得为空'
        ];

        //数据验证
        $valRel = $this->validate($param, $rule, $errMsg);
        if ($valRel !== true)
        {
            throw new BusinessException($valRel);
        }

        //提交查询
        $response = app(\app\api\logic\VipCourse::class)->getList($param);

        //返回
        return $this->response($response);
    }

    /**
     * VIP课程产品列表
     * @return Json
     * @throws BusinessException
     */
    public function getProductList(): Json
    {
        //外部参数
        $param = $this->request->param();

        //验证规则
        $rule = [
            'professions_id' => 'require'
        ];

        //错误信息
        $errMsg = [
            'professions_id.require' => '专业id不得为空'
        ];

        //数据验证
        $valRel = $this->validate($param, $rule, $errMsg);
        if ($valRel !== true)
        {
            throw new BusinessException($valRel);
        }

        //提交查询
        $response = app(\app\api\logic\VipCourse::class)->getProductList($param);

        //返回
        return $this->response($response);
    }
}